home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / DNet / DGoInit.h < prev    next >
Text File  |  1996-07-05  |  6KB  |  208 lines

  1. // DGopherInit.h
  2. // d.g.gilbert
  3.  
  4.  
  5. #ifndef __DGOPHERINIT__
  6. #define __DGOPHERINIT__
  7.  
  8.  
  9. #include <DObject.h>
  10. #include <DList.h>
  11. #include <DControl.h>
  12. #include <DWindow.h>
  13. #include <DTableView.h>
  14.  
  15.  
  16. enum GopherTransferKind {
  17.     kTransferBinary, kTransferText, kTransferNone
  18.     };
  19.  
  20. class DGodocKindList;
  21.  
  22.  
  23. class DGopherMap : public DObject {
  24. public:
  25.     long        fId;                        // internal id of this type
  26.     short        fHandlerType;   // none,internal,launch=external,???     
  27.     unsigned short fPreference; // priority over other view types (0=never .. 64000 highest pri)
  28.     DGodocKindList    *    fKind;                        // go+, main/subtype
  29.     DGodocKindList    *    fServerSuffixes;  // list of any server suffixes to map to this kind 
  30.     char        fServerType;
  31.  
  32.         // local info
  33.     char        fLocalType;          // gopher type
  34.     char        fMapSuffixWhen; // suffix-local type map=never,default,always,??
  35.     short        fTransferType;  // default=binary,text
  36.     long        fMacType, fMacSire;  // mac file typing
  37.     char    *    fSuffix;                // unix,dos filename suffix
  38.     char    *    fHandlerName;        // mac,other? handler-app name
  39.     short        fCommand;                // gopher command #  
  40.     Boolean    fSaveToDisk;         // option for internal handlers
  41.     char    *    fParameters;        // temp data for reading parameters
  42.     short        fStatus;                // changed,added,deleted flag
  43.     Boolean fServerSuffixesChanged, fServerLocalChanged;
  44.         
  45.     DGopherMap();
  46.     virtual ~DGopherMap();
  47.     virtual    Boolean suicide(void);  // prefered to delete 
  48.     virtual    Boolean suicide(short ownercount);
  49.     
  50.     virtual    void Initialize();
  51.     virtual void ReadData(short datakind);
  52.     virtual void ReadKind(); 
  53.     virtual void ReadServerType();
  54.     virtual void ReadServerSuffix();
  55.     virtual void ReadLocalHandling();
  56.  
  57.     virtual    Boolean Map(DGopher* aGopher);
  58.     
  59.     virtual const char* GetID();
  60.     virtual void  SetID( char* s);
  61.     virtual void  SetParameters( char* params);
  62.     virtual const char* GetParameters();
  63.  
  64.     virtual const char* GetKind();
  65.     virtual void  SetKind( char* s);
  66.     virtual    const char* GetHandlerType();
  67.     virtual void  SetHandlerType( char* s);
  68.     virtual const char* GetHandlerName();
  69.     virtual void  SetHandlerName( char* s);
  70.     virtual const char* GetPreference();
  71.     virtual void  SetPreference( char* s);
  72.     
  73.     virtual    const char*    GetServerType();
  74.     virtual    void  SetServerType( char* s);
  75.     virtual    const char*    GetLocalType();
  76.     virtual    void  SetLocalType( char* s);
  77.     virtual    const char*    GetMapWhen();
  78.     virtual    void  SetMapWhen( char* when);
  79.     virtual    const char* GetMacTypeNSire();
  80.     virtual    void  SetMacTypeNSire( char* s);
  81.     virtual const char*    GetSuffix();
  82.     virtual void  SetSuffix( char* s);
  83.     virtual const char*    GetServerSuffixes();
  84.     virtual void  SetServerSuffixes( char* s);
  85.     virtual    Boolean GetTransferBinary();
  86.     virtual    void  SetTransferBinary(Boolean turnon = true);
  87.     virtual    Boolean GetSaveToDisk();
  88.     void SetSaveToDisk(Boolean turnon = true);
  89.     virtual    Boolean GetDisplay();
  90.     //virtual    void  SetDisplay(Boolean turnon);
  91.     virtual    short    GetCommand();
  92.     virtual    void  SetCommand();
  93. };
  94.  
  95.  
  96.  
  97. class DGopherMapList : public DList {
  98. public:
  99.     DGopherMapList();
  100.     DGopherMap* GopherMapAt(long index) { return (DGopherMap*) At(index); }
  101.     
  102.     void ReadParams(char* theId, char* params, short datakind);
  103.     void DeleteItem(char* theId);
  104.  
  105.     virtual DGopherMap* MatchID(long theId);  
  106.  
  107.     virtual DGopherMap* MatchHandlerKind(unsigned short& lastrank, char* aKind);  
  108.     virtual DGopherMap* MatchHandlerKind(DGopher* aGopher);  
  109.     virtual DGopherMap* MatchGopherType(char theType, Boolean matchAny);
  110.     virtual DGopherMap* MatchGopherType(DGopher* aGopher);
  111.     virtual DGopherMap* MatchSuffix(const char* pathname, char gopherType);  
  112.     virtual DGopherMap* MatchSuffix(DGopher* aGopher);  
  113.  
  114.     virtual DGopherMap*  GetPreferedFiletype(char* aKind, 
  115.                         long& macFileType, long& macCreator, char*& suffix);
  116.     virtual DGopherMap*  GetPreferedFiletype(DGopher* aGopher, 
  117.                         long& macFileType, long& macCreator, char*& suffix);
  118. };
  119.  
  120.  
  121.  
  122.  
  123. class DGoMapHandlerView;
  124.  
  125. class DGopherMapDoc : public DWindow 
  126. {
  127. public:
  128.     DGopherMapList * fItems;
  129.     DGoMapHandlerView * fListView;
  130.     DCheckBox * fServerTypeEnable;
  131.     DCheckBox * fServerSuffixEnable;
  132.     Boolean    fChanged;
  133.  
  134.     static  void UpdateGopherMap(short item, DGopherMap *gm);
  135.     static  Boolean EditHandler( char* itsKind = "text/plain", DGopherMap* item = NULL, short dlogKind = 4);
  136.     virtual void EditLocalHandling(DGopherMap* item, short dlogKind);
  137.     
  138.     DGopherMapDoc( long id, DGopherMapList* itsMappers);
  139.     //virtual ~DGopherMapDoc();
  140.  
  141.     virtual void Open();
  142.     virtual void Close();
  143.     virtual Boolean IsMyAction(DTaskMaster* action);
  144. };
  145.  
  146.  
  147. class DGoMapHandlerView : public DTableView 
  148. {
  149. public:
  150.     DGopherMapDoc *    fDoc;
  151.     DGopherMapList * fItems;
  152.     
  153.     DGoMapHandlerView(long id, DGopherMapDoc* itsDoc, short pixwidth, short pixheight);
  154.  
  155.     virtual void Drag(Nlm_PoinT mouse);
  156.     virtual void Hold(Nlm_PoinT mouse);
  157.     virtual void Release(Nlm_PoinT mouse);
  158.     virtual void DoubleClickAt(short row, short col);
  159.     virtual void SingleClickAt(short row, short col);
  160.     virtual DGopherMap* SelectedMapper();
  161.     virtual void GetReadyToShow();
  162.     virtual void DrawCell(Nlm_RecT r, short row, short col);
  163. };
  164.  
  165.  
  166.  
  167.  
  168.  
  169. class DGopherEditView : public DCluster {        
  170. public:
  171.     DGopher*    fGopher;
  172.     char*            fOldURL;
  173.     
  174.     DGopherEditView(long id, DView* itsSuperior, DGopher* itsGopher,
  175.             const char* oldURL, short width, short height, Boolean hidden = false, 
  176.             char* title = NULL);
  177.     virtual ~DGopherEditView();
  178.     virtual void InstallControls();
  179.     virtual void Answers();
  180. };
  181.  
  182.  
  183. class DGopherEditWindow : public DWindow 
  184. {
  185. public:
  186.     const char     *fName, *fHost, *fPort, *fPath, *fURL;
  187.     DGopher            *fGopher;
  188.     Boolean            fEditAll;
  189.     DGopherEditView    * fView;
  190.     
  191.     DGopherEditWindow(DGopher* itsGopher, Boolean editAll);
  192.     virtual ~DGopherEditWindow();
  193.     virtual void OkayAction();
  194.     virtual void Open();
  195. };
  196.  
  197.  
  198.  
  199. extern  Boolean        gDoSuffix2MacMap, gNeedTypeChange;
  200. extern  DGopherMapList*        gGopherMap;
  201.  
  202. void EditGopherMap();
  203. void InitializeUGopher();
  204.  
  205.  
  206.  
  207. #endif
  208.